package com.sleepan.admin.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: 方振毅
 * @Date: 2019/6/15 9:52 PM
 */
public class TimeUtil {
    public static String getCurrentTime(){
        /**
         * 设置日期格式
         */
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df.format(new Date());
    }

    public static String formatTime(Long time){
        /**
         * 设置日期格式
         */
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df.format(new Date(time));
    }

    public static Long getTimeLongFromTimeStr(String time) throws ParseException {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df.parse(time).getTime();
    }

}
